from pymouse import PyMouse
from pykeyboard import PyKeyboard
import time


mouse = PyMouse()
keyBoard = PyKeyboard()

# 保险先延时一下, 防误触
time.sleep(1)
mouse.click(1633, 605)


# 阻塞, 测试用
while True:
    time.sleep(1)

#################### 1. 键盘模拟 #######################

# 键盘的映射查阅windows.py的special_key_assignment方法

# 模拟Home键
keyBoard.tap_key(keyBoard.numpad_keys['Home'])

# 模拟F2
keyBoard.tap_key(keyBoard.function_keys[2])

# 模拟ctrl+a
keyBoard.press_key(keyBoard.control_l_key)
keyBoard.tap_key('a')
keyBoard.release_key(keyBoard.control_l_key)

# 模拟键盘输入文字  
keyBoard.type_string('hello world')

# 模拟方向左键
keyBoard.tap_key(keyBoard.left_key)


#################### 2. 鼠标模拟 #######################

# 获取鼠标位置, 返回一个元组
print(mouse.position)

# 模拟鼠标位移, xy为目标坐标
mouse.move(660, 800) 

# 模拟左键单击
mouse.click(1633, 715)     

# 模拟左键双击
mouse.click(1633, 715, button=1, n=2)  

# 模拟右键单击 
mouse.click(1633, 715, button=2, n=1)   

# 模拟中键单击 
mouse.click(1633, 715, button=3, n=1)  

# 模拟双击左键, 间隔为0.1ms
mouse.click(1633, 715)
time.sleep(0.1)
mouse.click(1633, 715)



